//
// ConstantFragmentation.cxx
//
// Created by TB on 11/18/11.
// Copyright 2011 BNL. All rights reserved.
//

#include <TRandom3.h>

#include "tppmc/ConstantFragmentation.h"
#include "tppmc/Enumerations.h"

namespace tppmc {
   
   
   ConstantFragmentation::ConstantFragmentation(double fraction)
   : mFraction(fraction) {
   }
   
   
   ConstantFragmentation::~ConstantFragmentation() {
   }
   
   
   std::vector<Hadron> ConstantFragmentation::Fragment(const pythpart& parton,
                                          double) {
      // No fragmentation, just a constant fraction
      
      Hadron hadron;
      
      hadron.px = Fraction() * parton.px;
      hadron.py = Fraction() * parton.py;
      hadron.pz = Fraction() * parton.pz;
      hadron.mParton = parton;
      hadron.z = 1;
      hadron.lasthad = 1;
      
      // Randomly throw an integer from -1 to +1 and select
      // the hadron species from that.
      switch(gRandom->Integer(3) - 1) {
         case -1:
            hadron.type = PIMINUS;
            break;
         case  0:
            hadron.type = PIZERO;
            break;
         case  1:
            hadron.type = PIPLUS;
            break;
      } // switch
      
      std::vector<Hadron> products;
      products.push_back(hadron);
      return products;
   }
   
   
} // namespace tppmc
